<template>
  <div>
    <el-form :model="inputForm">
      <el-form-item prop="username">
        <el-input v-model="inputForm.username"/>
      </el-form-item>
      <el-form-item prop="password">
        <el-input v-model="inputForm.password"/>
      </el-form-item>
      <el-form-item>
        <el-button @click="loginSubmit">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data () {
    return {
      inputForm: {
        username: '',
        password: ''
      }
    }
  },
  methods: {
    loginSubmit () {
      this.$http.post('/sys/user/login', this.inputForm).then(({ data }) => {
        localStorage.setItem('token', data.token)
        this.$router.push({ name: 'main' }).catch(() => {
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
